﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NovoSerDes.A2B.controls
{
    public partial class Enabled_Disabled_button : UserControl
    {
        private CustomButton myButton;
        public Enabled_Disabled_button()
        {
            InitializeComponent();
            myButton = new CustomButton();
            myButton.Text = "Enabled";
            myButton.Size = new Size(180, 33);
            myButton.BackColor = Color.LightGreen;
            myButton.Dock = DockStyle.Fill;
            myButton.Click += (s, e) =>
            {
                if (myButton.Text == "Enabled")
                {
                    myButton.Text = "Disabled";
                    myButton.BackColor = Color.LightCoral;
                }
                else if(myButton.Text == "Disabled")
                {
                    myButton.Text = "Enabled";
                    myButton.BackColor = Color.LightGreen;
                }
                else if( myButton.Text == "Do Not Report")
                {
                    myButton.Text = "Report";
                    myButton.BackColor = Color.LightGreen;
                }
                else if (myButton.Text == "Report")
                {
                    myButton.Text = "Do Not Report";
                    myButton.BackColor = Color.LightCoral;
                }
            };
            this.Controls.Add(myButton);
            this.Size = new Size(180, 33);
        }
        /// <summary>
        /// Browsable(true): 确保属性在属性面板中可见。
        /// DesignerSerializationVisibility(DesignerSerializationVisibility.Visible) : 确保属性值在设计器中可序列化
        /// Category("Appearance") 和 Description("Sets the text associated with the button."): 这些属性用于在属性面板中更好地组织和描述 Text 属性。
        /// </summary>
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Category("Appearance")]
        [Description("Sets the text associated with the button.")]
        public override string Text
        {
            get { return myButton.Text; }
            set { myButton.Text = value; }
        }

        private Color buttonColor = Color.LightGreen;

        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Category("Appearance")]
        [Description("Sets the color of the button when enabled.")]
        public Color ButtonColor
        {
            get { return buttonColor; }
            set
            {
                buttonColor = value;
                if (myButton.Text == "Enabled")
                {
                    myButton.BackColor = buttonColor;
                }
            }
        }
    }
}
